package com.qzsoft.zhjd.asphalt.modules.asphaltdataweight.service.impl;

import java.util.Map;

import com.qzsoft.zhjd.asphalt.modules.asphaltdataweight.dto.AsphaltDataWeightDto;
import com.qzsoft.zhjd.asphalt.modules.asphaltdataweight.dto.ProduceWeightDto;
import com.qzsoft.zhjd.asphalt.modules.asphaltdataweight.entity.AsphaltDataWeightEntity;
import com.qzsoft.zhjd.asphalt.modules.asphaltdataweight.mapper.AsphaltDataWeightMapper;
import com.qzsoft.zhjd.asphalt.modules.asphaltdataweight.service.AsphaltDataWeightService;
import com.qzsoft.zhjd.common.annotation.ZhjdDataFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzsoft.zhjd.common.components.BaseServiceComponent;

/**
 * @ClassName AsphaltDataWeightServiceImpl
 * @Description 重量业务接口实现
 * @author linhuawei
 * @since 2021-12-04
 */
@Service
public class AsphaltDataWeightServiceImpl extends ServiceImpl<AsphaltDataWeightMapper, AsphaltDataWeightEntity>
        implements AsphaltDataWeightService {

    @Autowired
    private BaseServiceComponent baseServiceComponent;

    @ZhjdDataFilter
    @Override
    public IPage<AsphaltDataWeightDto> pageDto(Map<String, Object> params) {
        IPage<AsphaltDataWeightDto> page = baseServiceComponent.getPage(params, AsphaltDataWeightDto.class);
        return baseMapper.queryDto(page, params);
    }

    @ZhjdDataFilter
    @Override
    public IPage<ProduceWeightDto> produceWeight(Map<String, Object> params) {
        IPage<ProduceWeightDto> page = baseServiceComponent.getPage(params, ProduceWeightDto.class);
        page = baseMapper.produceWeight(page, params);
        /*
        page.getRecords().forEach(item -> {
            params.put("dischargeTime", item.getDischargeTime());
            BigDecimal totalWeight = baseMapper.produceTotalWeight(params);
            item.setTotalWeight(totalWeight);
        });
        */
        return page;
    }

}
